﻿using System.Web.Mvc;

namespace GuRenFang.Common
{
   public static class HtmlHelpers
   {
       /// <summary>
       /// This is a simple HTML Helper which truncates a string to a given length
       /// </summary>
       /// <param name="helper">HTML Helper being extended</param>
       /// <param name="input">Input string to truncate</param>
       /// <param name="length">Max length of the string</param>
       /// <returns></returns>
      public static string Truncate(this HtmlHelper helper, string input, int length)
       {
           return input.Length <= length ? input : input.Substring(0, length) + "...";
       }


       /// <summary>
       /// This is a simple HTML Helper which removes all html tags 
       /// </summary>
       /// <param name="helper">HTML Helper being extended</param>
       /// <param name="input">Input string to remove all html tags</param>
       /// <returns></returns>
      public static string RemoveHtmlTag(this HtmlHelper helper, string input)
       {
           return System.Text.RegularExpressions.Regex.Replace(input, "<[^>]*>", "");
       }
       
   }
}
